//显示增量启用状态
function showStrategyIncrementEnable(driver) {
	var $incrementEnable = $('#driverStrategyIncrementEnable');
	var $incrementEnableCheck = $incrementEnable.find("input[type='checkbox']");
	// 回现增量配置
	if (driver.policy.increment) {
		// 获取驱动增量启用状态值
		var enable = driver.policy.increment.enable == "true";
		$incrementEnableCheck.prop({
			checked : enable
		});
		// 获取当前值
		$incrementEnableCheck.val(enable);
	}
	// 初始化switch插件
	$incrementEnable.find("input").bootstrapSwitch({
		onText : '启用',
		offText : '禁用'
	}).on('switchChange.bootstrapSwitch', function(event, state) {
		// 获取当前值
		$incrementEnableCheck.val(state);
	});
}

// 显示增量策略
function showStrategyIncrementMysql(driver) {
	if(driver.sourceConfig.driverClassName=='com.mysql.jdbc.Driver'){
		$("#sourceStrategyIncrementDatabaseMysql").removeClass("hidden");
		// 回现驱动数据源的信息
		var url = driver.sourceConfig.url;
		var urlInfo = url.split(/[:/?]/);
		$("#sourceStrategyIncrementDatabase").val(urlInfo[6]);
		$("#sourceStrategyIncrementTable").val(driver.sourceConfig.table);
		if(driver.policy.increment){
			$("#sourceStrategyIncrementIp").val(driver.policy.increment.ip);
			$("#sourceStrategyIncrementPort").val(driver.policy.increment.port);
			$("#sourceStrategyIncrementInstance").val(driver.policy.increment.instance);
		}
	}
}

//显示增量策略Oracle
function showStrategyIncrementOracle(driver) {
	var $scanAll = $('#sourceStrategyIncrementScanAll');
	// 初始化icheck插件
	$scanAll.find("input").iCheck({
		labelHover : false,
		cursor : true,
		radioClass : 'iradio_flat-blue',
	});
	if(driver.sourceConfig.driverClassName=='oracle.jdbc.OracleDriver'){
		$("#sourceStrategyIncrementDatabaseOracle").removeClass("hidden");
	}
}

$(function() {
	// 显示增量启用状态
	showStrategyIncrementEnable(driver);
	
	// 显示增量策略Mysql
	showStrategyIncrementMysql(driver);
	
	// 显示增量策略Oracle
	showStrategyIncrementOracle(driver);
});